using UnityEngine;

public class DamageOfRender : EventComponentArea<DamageOfRender>
{
	public static bool enabledComponents = true;

	[Tooltip("SpriteRenderer, для извлечения спрайта")]
	public SpriteRenderer render;

	[Tooltip("Файл-источник со спрайтами, из которого будет получена информация о повреждении")]
	public ListDamagesSprites listDamages;

	[HideInInspector]
	public string idDamage = string.Empty;

	[HideInInspector]
	public Sprite replaceSprite;

	public override bool ShowIconGizmos(AreaDamage area)
	{
		return base.enabled && idDamage != string.Empty;
	}

	public override void Activation(AreaDamage area)
	{
		if (DamageOfSprite.enabledComponents)
		{
			if (replaceSprite != null)
			{
				render.sprite = replaceSprite;
			}
			render.sprite = listDamages.GetSprite(render.sprite, idDamage);
			render.gameObject.SetActive(value: true);
			if (onActivationListener != null)
			{
				onActivationListener(this);
			}
			UnityEngine.Object.Destroy(this);
		}
	}
}
